using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AlgorithmsVisualized
{
    public partial class frmNewEdge : Form
    {
        private double _weight;

        public double Weight
        {
            get { return _weight; }
        }

        public frmNewEdge()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            _weight = double.Parse(txtWeight.Text);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void txtWeight_Validating(object sender, CancelEventArgs e)
        {
            try
            {
                _weight = double.Parse(txtWeight.Text);
            }
            catch
            {
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, "Only double values allowed");
            }
        }

        private void txtWeight_Validated(object sender, EventArgs e)
        {
            errorProvider1.SetError(txtWeight, "");
        }

        private void lnkCancel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}